<template>
  <view class="wallet-page">
    <view class="wallet-card">
      <view class="card-title">总余额(元)</view>
      <view class="card-total">¥ {{ balance }}</view>

      <!-- <view class="card-bottom">
      <view class="bottom-item item-left">
        <text>可提现余额</text>
        <text>0.'00'</text>
      </view>
      <view class="bottom-item item-right">
        <text>冻结余额</text>
        <text>0.'00'</text>
      </view>
    </view> -->
    </view>

    <!-- <view class="footer">
    <van-button round type="warning" plain class="footer-btn" color="#FF8100" bind:tap="recharge">充值</van-button>
    <van-button round type="warning" class="footer-btn" color="#FF8100" bind:tap="cashout">提现</van-button>
  </view> -->

    <!-- <view class="footer1">
    <van-button round type="warning1" class="footer-btn" color="#FF8100" bind:tap="recharge">充值</van-button>
  </view> -->
    <view class="footer1">
      <button
        class="submit_pay"
        color="#EAC41F"
        @click="withdraw"
      >
        余额提现
      </button>
    </view>
  </view>
</template>

<script>
const app = getApp();
let Sign = app.globalData.Sign;
let Store = app.globalData.Store;
let Api = app.globalData.Api;
export default {
  data() {
    return {
      balance: 0,
      userId: ''
    };
  },
  onLoad() {
    const userId = Store.getItem('user_id');
    // this.setData({
    this.userId = userId
    // });
  },
  onShow() {
    const userId = this.userId;
    const signObject = {
      userId
    };
    const signvalue = Sign.signutil(signObject);
    app.globalData
      .get(Api.getUserByUserId, {
        userId,
        sign: signvalue
      })
      .then((res) => {
        console.log(res);
        // this.setData({
        this.balance = res.list.balance
        // });
      })
      .catch((e) => {
        console.log(e);
      });
  },
  methods: {
    withdraw() {
      const userId = this.userId;
      const signObject = {
        userId
      };
      const signvalue = Sign.signutil(signObject);
      app.globalData
        .get(Api.mpToSubmit, {
          userId,
          sign: signvalue
        })
        .then((res) => {
          console.log(res);
          if (res.code == 0) {
            uni.showToast({
              title: '提交成功',
              icon: 'success'
            });
          }
        })
        .catch((e) => {
          console.log(e);
        });
    },

    recharge() {
      uni.navigateTo({
        url: '/pages/walletSelMoney/walletSelMoney'
      });
    },

    cashout() {
      uni.navigateTo({
        url: '/pages/sysCashOut/sysCashOut'
      });
    }
  }
};
</script>
<style>
@import "./wallet.css";
</style>
